<!DOCTYPE html>
<html lang="en">
<head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <meta http-equiv="X-UA-Compatible" content="ie=edge">
      <title>Document</title>
      <style>
            *{
                  margin: 0;padding: 0;
            }
            #box{
                  width: 100px;
                  height: 100px;
                  background: #333;
                  position: absolute;
            }
            #container{
                  width : 800px;
                  height: 400px;
                  margin: 0 auto;
                  background: #ddd;
                  position: relative;
            }

      </style>
</head>
<body>
      <div id="container">
            <div id="box"></div>
      </div>


      <script>
            var box = document.getElementById("box");
            var box_left = box.offsetLeft
            var timer = null;
            timer = setInterval( function (){
                  box_left += 10;
                  box_left >= 700 ? box_left =  700 : ""; 
                  box.style.left = box_left + "px";
            } , 50)
      </script>
</body>
</html>